package com.study.arrayall.list;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class ListDelete {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>(Arrays.asList("a1","a2","a3","a4","a5","a6","a7","a8","a9"));
        for (String str:list){
            if (str.contains("b")) {
                list.remove(str);
            }
        }

        /**正确删除方法**/
        for(Iterator<String> ite=list.iterator(); ite.hasNext();){
            String str=ite.next();
            if(str.contains("b")){
                ite.remove();
            }
        }
    }
}
